package com.yunhe.option.service.data.impl;

import com.yunhe.option.domain.data.Version;
import com.yunhe.option.repository.data.VersionRepository;
import com.yunhe.option.service.data.VersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class VersionServiceImpl implements VersionService {

    @Autowired
    private VersionRepository versionRepository;

    @Override
    public Version create(Version version) {
        return versionRepository.save(version);
    }

    @Override
    public void deleteByType(String type) {
        Version version = versionRepository.searchLatestVersion(type);
        versionRepository.delete(version);
    }

    @Override
    public Version update(Version version) {
        return versionRepository.save(version);
    }

    @Override
    public Version searchLatestVersionByType(String type) {
        return versionRepository.searchLatestVersionByType(type);
    }
}
